home *** CD-ROM | disk | FTP | other *** search
GW-BASIC | 1997-01-27 | 6.9 KB | 289 lines |
- 10 'BATTERY - 23 MAR 94 rev. 27 SEP 96
- 20 CLS:KEY OFF
- 30 IF EX$=""THEN EX$="EXIT"
- 40 ON ERROR GOTO 240
- 50 COLOR 7,0,1
- 60 NA$="BATTERY.DAT"
- 70 UL$=STRING$(80,205)
- 80 DIM A$(128,5),F$(50,2)
- 90 DIM B$(9)
- 100 '
- 110 DATA #44/76/G13
- 120 DATA 6v lantern - screw term.
- 130 DATA 6v lantern - spring term.
- 140 DATA 9v,AAA,AA,C,D,OTHER
- 150 FOR I=1 TO 9:READ B$(I):NEXT I
- 160 '
- 170 '.....start
- 180 COLOR 15,2
- 190 PRINT " BATTERY SCHEDULE";TAB(57);"by George Murphy VE3ERP ";
- 200 COLOR 1,0:PRINT STRING$(80,223);
- 210 COLOR 7,0
- 220 GOTO 540
- 230 '
- 240 '.....error trap
- 250 IF ERR=53 AND ERL=550 THEN 280
- 260 CLS:PRINT "Error";ERR;"in line";ERL:END
- 270 '
- 280 VIEW PRINT 3 TO 24:CLS:VIEW PRINT:LOCATE 4
- 290 PRINT " Your battery data will be contained in a file named ";NA$;"."
- 300 PRINT
- 310 PRINT" No battery data has yet been entered so the file does not yet exist."
- 320 PRINT
- 330 PRINT " The file will be created automatically ";
- 340 PRINT "as soon as you enter your first data."
- 350 PRINT
- 360 PRINT " The file can be edited or deleted at any time."
- 370 PRINT
- 380 PRINT " If you do not want to start the file now the program will return ";
- 390 PRINT "to the last"
- 400 PRINT " previous menu."
- 410 PRINT:COLOR 15,0
- 420 PRINT " Do you want to create the file and start entering battery ";
- 430 PRINT "data now?";
- 440 COLOR 0,7
- 450 PRINT " (y/n) "
- 460 Z$=INKEY$
- 470 COLOR 7,0
- 480 IF Z$="N"OR Z$="n"THEN CLS:RUN EX$
- 490 IF Z$="Y"OR Z$="y"THEN CLS:GOTO 1700
- 500 GOTO 460
- 510 OPEN"O",1,"\data\batt\"+NA$
- 520 CLOSE
- 530 '
- 540 '.....load file
- 550 OPEN "I",1,"\data\batt\"+NA$
- 560 N=0
- 570 IF EOF(1)THEN 610
- 580 N=N+1:FOR Y=1 TO 5
- 590 INPUT# 1,A$(N,Y):NEXT Y
- 600 GOTO 570
- 610 CLOSE
- 620 '
- 630 '.....main menu
- 640 VIEW PRINT 3 TO 24:CLS:VIEW PRINT:LOCATE 3
- 650 PRINT TAB(8);
- 660 PRINT "This program compiles an inventory of all your battery operated"
- 670 PRINT TAB(8);
- 680 PRINT "devices, lists the quantity and type of batteries in each device"
- 690 PRINT TAB(8);
- 700 PRINT "and records the date when the batteries were last changed."
- 710 PRINT
- 720 PRINT TAB(8);
- 730 PRINT "When you change batteries don't always throw the old ones away."
- 740 PRINT TAB(8);
- 750 PRINT "Most clocks will run for months on batteries that are too weak"
- 760 PRINT TAB(8);
- 770 PRINT "for anything else."
- 780 LOCATE 11,1
- 790 PRINT UL$;
- 800 PRINT " Press number in < > to:";
- 810 PRINT UL$;
- 820 PRINT " < 1 > ADD a listing"
- 830 PRINT " < 2 > EDIT or DELETE a listing"
- 840 PRINT " < 3 > DISPLAY/PRINT listings"
- 850 PRINT " < 4 > DELETE entire file ";:COLOR 12,0:PRINT "( CAUTION ! )"
- 860 COLOR 7,0
- 870 PRINT UL$;
- 880 PRINT " < 0 > EXIT"
- 890 Z$=INKEY$:IF Z$=""THEN 890
- 900 IF Z$="0"THEN CLS:RUN EX$
- 910 IF ASC(Z$)<49 OR ASC(Z$)>52 THEN 890
- 920 IF Z$="1"THEN CLS:GOTO 1700
- 930 IF Z$="2"THEN CLS:GOTO 2350
- 940 IF Z$="3"THEN 990
- 950 IF Z$="4"THEN CLS:GOTO 1120
- 960 GOTO 890
- 970 '
- 980 '.....sort options
- 990 LOCATE 12,24:PRINT " sort listings by:
- 1000 VIEW PRINT 14 TO 24:CLS:VIEW PRINT:LOCATE 14
- 1010 PRINT " < 5 > DEVICE"
- 1020 PRINT " < 6 > BATTERY type"
- 1030 PRINT " < 7 > DATE of last replacement"
- 1040 PRINT UL$;
- 1050 Z$=INKEY$:IF Z$=""THEN 1050
- 1060 IF ASC(Z$)<53 OR ASC(Z$)>55 THEN 1050
- 1070 IF Z$="5"THEN ST=0:GOSUB 1770:GOTO 2000
- 1080 IF Z$="6"THEN ST=1:GOSUB 1770:GOTO 2000
- 1090 IF Z$="7"THEN ST=2:GOSUB 1770:GOTO 2000
- 1100 GOTO 1050
- 1110 '
- 1120 '.....delete file
- 1130 BEEP
- 1140 LOCATE 13,10:COLOR 15,0
- 1150 PRINT " ARE YOU SURE YOU WANT TO DELETE ENTIRE FILE ? ";
- 1160 COLOR 14,6:PRINT " y/n ":COLOR 7,0
- 1170 Z$=INKEY$
- 1180 IF Z$="n"THEN CLS:GOTO 170
- 1190 IF Z$="y"THEN CLS:GOTO 1210
- 1200 GOTO 1170
- 1210 KILL"\data\batt\battery.dat"
- 1220 CLS:RUN EX$
- 1230 '
- 1240 '.....sort & save data
- 1250 ST=0:GOSUB 1770 'sort by device
- 1260 OPEN "O",1,"\data\batt\"+NA$
- 1270 FOR Z=1 TO N
- 1280 WRITE# 1,A$(Z,1),A$(Z,2),A$(Z,3),A$(Z,4),A$(Z,5)
- 1290 NEXT Z
- 1300 CLOSE
- 1310 GOTO 170
- 1320 '
- 1330 '.....convert to upper case
- 1340 FOR U=1 TO LEN(I$):V=ASC(MID$(I$,U,1)):IF V=44 THEN RETURN
- 1350 IF V>96 AND V<123 THEN MID$(I$,U,1)=CHR$(V-32)
- 1360 NEXT U:RETURN
- 1370 '
- 1380 '.....inputs
- 1390 LINE INPUT " ENTER: Device category (e.g. clock, radio etc.).....? ";I$
- 1400 GOSUB 1330:RETURN
- 1410 '
- 1420 LINE INPUT " ENTER: Device further description/location..........? ";I$
- 1430 RETURN
- 1440 '
- 1450 LINE INPUT " ENTER: Number of batteries in device............... ? ";I$
- 1460 RETURN
- 1470 '
- 1480 '.....battery description
- 1490 PRINT UL$;
- 1500 PRINT " Press number in < > to select battery:"
- 1510 PRINT UL$;
- 1520 FOR J=1 TO 9
- 1530 PRINT " <";J;"> ";B$(J)
- 1540 NEXT J
- 1550 PRINT UL$;
- 1560 Z$=INKEY$:IF VAL(Z$)=0 THEN 1560
- 1570 I$=B$(VAL(Z$)):GOTO 1590
- 1580 GOTO 1560
- 1590 LN=CSRLIN-13
- 1600 VIEW PRINT LN TO 24:CLS:VIEW PRINT
- 1610 IF Z$="9" THEN 1630
- 1620 LOCATE LN,9:PRINT I$:GOTO 1650
- 1630 LOCATE LN
- 1640 LINE INPUT " ENTER: Battery size or description................. ? ";I$
- 1650 RETURN
- 1660 '
- 1670 LINE INPUT " ENTER: Date current batteries installed (yy/mm).... ? ";I$
- 1680 RETURN
- 1690 '
- 1700 '.....new listing
- 1710 N=N+1
- 1720 PRINT " NEW LISTING"
- 1730 PRINT UL$;
- 1740 FOR Z=1 TO 5:ON Z GOSUB 1390,1420,1450,1480,1670:A$(N,Z)=I$
- 1750 NEXT Z:Z=N:CLS:GOTO 2390
- 1760 '
- 1770 '.....sort
- 1780 CLS
- 1790 SN=N:SM=SN
- 1800 SM=INT(SM/2):IF SM=0 THEN 1980
- 1810 SK=SN-SM:SJ=1
- 1820 SI=SJ
- 1830 SL=SI+SM
- 1840 IF ST=0 THEN 1870
- 1850 IF ST=1 THEN 1890
- 1860 IF ST=2 THEN 1910
- 1870 SORT1$=A$(SI,1)+A$(SI,2)
- 1880 SORT2$=A$(SL,1)+A$(SL,2):GOTO 1930 'sort by device
- 1890 SORT1$=A$(SI,4)+A$(SI,1)
- 1900 SORT2$=A$(SL,4)+A$(SL,1):GOTO 1930 'sort by battery
- 1910 SORT1$=A$(SL,5)+A$(SL,1)
- 1920 SORT2$=A$(SI,5)+A$(SI,1):GOTO 1930 'sort by date
- 1930 IF SORT1$<=SORT2$ THEN 1960
- 1940 FOR X=1 TO 5:SWAP A$(SI,X),A$(SL,X):NEXT X
- 1950 SI=SI-SM:IF SI>0 THEN 1830
- 1960 SJ=SJ+1:IF SJ>SK THEN 1800
- 1970 GOTO 1820
- 1980 RETURN
- 1990 '
- 2000 '.....screen print
- 2010 PRINT UL$;
- 2020 PRINT TAB(24);" B A T T E R Y S C H E D U L E "
- 2030 PRINT UL$;
- 2040 LOCATE CSRLIN-1,8:PRINT "<0xCB!>"
- 2050 PRINT " sort# OPEN DEVICE ";
- 2060 PRINT SPC(6);"(Year and month shown are date of last replacement)
- 2070 PRINT UL$;
- 2080 LOCATE CSRLIN-1,8:PRINT "LOCATE"
- 2090 FOR Z=1 TO N
- 2100 N$=STR$(Z)
- 2110 IF LEN(N$)<4 THEN N$=" "+N$:GOTO 2110
- 2120 PRINT N$;": "; 'sort number
- 2130 IF ST=0 THEN COLOR 15,1 ELSE COLOR 7,0
- 2140 PRINT A$(Z,1); 'device
- 2150 COLOR 7,0
- 2160 PRINT ", ";A$(Z,2) 'description
- 2170 IF ST=2 THEN COLOR 15,1 ELSE COLOR 7,0
- 2180 LOCATE CSRLIN,11:PRINT A$(Z,5); 'date
- 2190 COLOR 7,0
- 2200 PRINT ": ";A$(Z,3);" x "; 'quantity
- 2210 IF ST=1 THEN COLOR 15,1 ELSE COLOR 7,0
- 2220 PRINT A$(Z,4) 'type
- 2230 COLOR 7,0
- 2240 PRINT "";
- 2250 IF CSRLIN<24 THEN 2280
- 2260 GOSUB 2760:CLS
- 2270 PRINT
- 2280 NEXT Z
- 2290 PRINT UL$;
- 2300 PRINT " Date: ";DATE$
- 2310 GOSUB 2760:COLOR 7,0
- 2320 VIEW PRINT 3 TO 24:CLS:VIEW PRINT
- 2330 CLS:GOTO 780 'return to menu
- 2340 '
- 2350 '.....edit/delete
- 2360 INPUT "ENTER: Sort number.....";Z
- 2370 CLS
- 2380 PRINT " #";Z;
- 2390 LOCATE CSRLIN,9
- 2400 PRINT ": ";A$(Z,1);", ";A$(Z,2);" - ";A$(Z,3);" x ";A$(Z,4)
- 2410 PRINT TAB(9);": installed ";A$(Z,5)
- 2420 PRINT UL$;
- 2430 FOR Y=1 TO 5
- 2440 PRINT " Line";Y;": ";A$(Z,Y)
- 2450 NEXT Y
- 2460 PRINT UL$;
- 2470 PRINT " Press number in ( ) to:"
- 2480 PRINT UL$;
- 2490 FOR Y=1 TO 5:PRINT " (";Y;") Change Line";Y:NEXT Y
- 2500 PRINT " ( 6 ) ACCEPT as is"
- 2510 PRINT " ( 7 ) DELETE listing"
- 2520 PRINT UL$;
- 2530 Z$=INKEY$:Q=VAL(Z$):IF Q<1 OR Q>7 THEN 2530
- 2540 IF Z$="1"THEN GOSUB 1390:A$(Z,1)=I$:CLS:GOTO 2380
- 2550 IF Z$="2"THEN GOSUB 1420:A$(Z,2)=I$:CLS:GOTO 2380
- 2560 IF Z$="3"THEN GOSUB 1450:A$(Z,3)=I$:CLS:GOTO 2380
- 2570 IF Z$="4"THEN 2630
- 2580 IF Z$="5"THEN GOSUB 1670:A$(Z,5)=I$:CLS:GOTO 2380
- 2590 IF Z$="6"THEN CLS:GOTO 1240
- 2600 IF Z$="7"THEN CLS:GOTO 2660
- 2610 GOTO 2530
- 2620 '
- 2630 VIEW PRINT 9 TO 24:CLS:VIEW PRINT:LOCATE 9
- 2640 GOSUB 1480:A$(Z,4)=I$:CLS:GOTO 2380
- 2650 '
- 2660 '.....delete listing
- 2670 LOCATE 13,15:COLOR 15,4
- 2680 PRINT " Are you sure you want this listing deleted ? (y/n) "
- 2690 COLOR 7,0
- 2700 Z$=INKEY$:IF Z$="n"THEN CLS:GOTO 170
- 2710 IF Z$="y"THEN 2720 ELSE 2700
- 2720 FOR X=Z TO N:FOR Y=1 TO 5
- 2730 A$(X,Y)=A$(X+1,Y):NEXT Y:NEXT X:N=N-1
- 2740 CLS:GOTO 1240 'save
- 2750 '
- 2760 'HARDCOPY
- 2770 GOSUB 2880:LOCATE 25,2:COLOR 14,6
- 2780 PRINT " Press 1 to print screen, 2 to print screen & ";
- 2790 PRINT "advance paper, or 3 to continue.";:COLOR 7,0
- 2800 Z$=INKEY$:IF Z$="3"THEN GOSUB 2880:RETURN
- 2810 IF Z$="1"OR Z$="2"THEN GOSUB 2880:GOTO 2830
- 2820 GOTO 2800
- 2830 FOR QX=1 TO 24:FOR QY=1 TO 80
- 2840 LPRINT CHR$(SCREEN(QX,QY));
- 2850 NEXT QY:NEXT QX
- 2860 IF Z$="2"THEN LPRINT CHR$(12)
- 2870 GOTO 2770
- 2880 LOCATE 25,1:PRINT STRING$(80,32);:RETURN
-